package com.yifeng.repo.base.mdm.console.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2024/1/30.
 */
@Getter
@AllArgsConstructor
public enum MdmTypeEnum {
    USER("user", "员工"),
    ADM_ORG("admOrg", "行政组织"),
    OPS_ORG("opsOrg", "营运组织"),
    STORE("store", "门店"),
    DICT("dict", "字典"),
    ;

    @EnumValue
    @JsonValue
    private final String code;

    private final String name;

    private static final Map<String, MdmTypeEnum> mappings = new HashMap<>(5);

    static {
        for (MdmTypeEnum value : values()) {
            mappings.put(value.getCode(), value);
        }
    }

    public static MdmTypeEnum resolve(String code) {
        return (code != null ? mappings.get(code) : null);
    }

}
